﻿module Main

open Core
open System
open System.IO
open MathNet.Numerics
open MathNet.Numerics.FSharp
open MathNet.Numerics.LinearAlgebra.Double

let lines = File.ReadAllLines("iris.data") |> Seq.filter (fun f -> f <> "")

let get_k str =
  match str with
  | "Iris-setosa" -> -1.0
  | "Iris-versicolor" -> 1.0
  | "Iris-virginica" -> -1.0
  | _ -> failwith "Not found"

let points = lines |> Seq.map 
                      (fun s -> 
                          let elem = s.Split([|','|], StringSplitOptions.RemoveEmptyEntries)
                          (DenseVector([|float elem.[0]; float elem.[1]; float elem.[2]; float elem.[3]; 1.|])), ref 0, (get_k elem.[4])) |> Seq.toArray    

let w = DenseVector([|0.;0.;0.;0.;0.|])

do Console.ReadLine() |> ignore